home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 1 Issue 2 / PDCD-1 - Issue 02.iso / _utilities / utilities / 004 / rdrag / RedDragSrc (.txt) < prev    next >
RISC OS BBC BASIC V Source  |  1994-08-21  |  9KB  |  199 lines

  1.  > RedDragSrc
  2. Kvsn$="1.10":fnm$="ReducdDrag":date$="21 Aug 1994":
  3.  or MID$(TIME$,5,11)
  4. ;bl$=
  5. 0:cr$=
  6. 13:lfcr$=
  7. 10+cr$:tab$=
  8. 9:esc$=
  9. 27:hspc$=
  10. *RemV=&15:
  11.  Buffer Remove vector number
  12.     <Service_Reset      =&27:
  13.  End of machine reset signalled
  14. FService_StartWimp  =&49:
  15.  Request by Desktop to start WIMP modules
  16. DService_StartedWimp=&4A:
  17.  Desktop indicates all tasks now active
  18. XDragASprite_Stop=&62401
  19. 1codesize=&1000:
  20.  org codesize:L%=org+codesize
  21.  A%=%1100 
  22.  %1110 
  23.  %0010
  24. ?P%=0:O%=org : 
  25.  So that addresses are offsets within module
  26. [OPT A%
  27. G                EQUD    appstart          ; Application start entry
  28. D                EQUD    init              ; Initialisation entry
  29. B                EQUD    finalise          ; Finalisation entry
  30. B                EQUD    servicecall       ; Service call entry
  31. ?                EQUD    titlestring       ; -> Title string
  32. >                EQUD    helpstring        ; -> Help string
  33. M                EQUD    keywordtable      ; -> Help/Command keyword table
  34. >                                          ; And no SWIs...
  35. .keywordtable
  36. &.startupname    EQUS    "Desktop_"
  37. 4.titlestring    EQUS    "ReducedDrag"+bl$:
  38. align
  39.  #                EQUD    startup
  40. !%                EQUD    &00000000
  41. ")                EQUD    startupsyntax
  42. #'                EQUD    startuphelp
  43. .zeroword
  44. &P.notindesktop   EQUD    0                 ; End of keyword table & error no.
  45. 'C.startuphelp    EQUS    "Use *Desktop to start ReducedDrag"+bl$
  46. )'.startupsyntax  EQUS    esc$+
  47. 1+bl$
  48.                 
  49. align
  50. ,G.fEscPressed    EQUD    0                 ; Has Escape been pressed
  51. .4; th keeps track of the state of our Wimp task -
  52. ; th = 0 => Not running
  53. 06; th =-1 => Not running, claimed Service_StartWimp
  54. 1J; th > 0 => Running, th is the task handle returned by Wimp_Initialise
  55. .th             EQUD    0
  56. 4F.servicecall    TEQ     r1,#Service_Reset ; End of machine reset ?
  57. 5P                TEQNE   r1,#Service_StartWimp ; Is the Desktop starting up ?
  58. 6O                TEQNE   r1,#Service_StartedWimp ; Has the Desktop started ?
  59. 7"                MOVNES  PC,r14
  60. 8F                TEQ     r1,#Service_Reset ; End of machine reset ?
  61. 9?                BEQ     init              ; Yes, so restart
  62. :"                LDR     r12,th
  63. ;1                CMP     r1,#Service_StartWimp
  64. <L                BEQ     servstartwimp     ; Is the Desktop starting up ?
  65. =K                                          ; Must be Service_StartedWimp
  66. >L                ADDS    r12,r12,#1        ; *Command may have failed, so
  67. ?C                STREQ   r12,th            ; `if (th==-1) th=0;'
  68. @"                MOV     PC,r14
  69. B;.servstartwimp  TEQ     r12,#0            ; Is th = 0 ?
  70. CN                MVNEQ   r12,#
  71. (-1)      ; Yes => not running & not already
  72. DM                STREQ   r12,th            ; tried to claim so set th = -1
  73. EL                ADREQ   r0,startupname    ; r0 -> *Command to start task
  74. FG                
  75. Q   r1,#0             ; and claim the service call
  76. G"                MOV     PC,r14
  77. I,.startup        STMFD   r13!,{r0-r2,r14}
  78. JF                MOV     r2,r0             ; Point to *Command tail
  79. KK                LDR     r14,th            ; Check for user trying it on
  80. L@                CMP     r14,#0            ; r14 should be -1
  81. MA                MOVMI   r0,#2             ; Enter Application
  82. NA                ADRMI   r1,titlestring    ; r1 -> module name
  83. O(                SWIMI   "XOS_Module"
  84. P+                LDMMIFD r13!,{r0-r2,PC}
  85. QJ                ADR     r0,notindesktop   ; No Wimp tasks, so complain
  86. RD                SWI     "OS_GenerateError"; we're not in desktop
  87. T8.description ; Wimp task name is up to tab character
  88. UT.helpstring     EQUS    "Reduced Drag"+tab$+vsn$+" ("+date$+") 
  89.  Olly Betts"+bl$
  90. align
  91. XG; Well, here's the start sequence at last! We only want one of this
  92. YC; task running, so must shut down the old one if it is running.
  93. Z$; NB *NO* stack set up - beware!
  94. [!.appstart       MOV     r0,#0
  95. \/                SWI     "XWimp_ReadSysInfo"
  96. ]!                TEQ     r0,#0
  97. ^%                SWIEQ   "OS_Exit"
  98. _J                BLVC    wimpclosedown     ; Shut down any current task
  99. `D                MOVVC   r0,#300           ; Know about Wimp 3.00
  100. aJ                LDRVC   r1,TASK           ; Indicate RISC OS Wimp task
  101. bB                ADRVC   r2,description    ; r2 -> program name
  102. cQ                ADRVC   r3,zeroword       ; For Wimp 3.00+, -> no msgs wanted
  103. d.                SWIVC   "XWimp_Initialise"
  104. e<                MOVVC   r4,r0             ; Wimp version
  105. fE                STRVC   r1,th             ; Save Wimp task handle
  106. g$                MOVVC   r0,#RemV
  107. h#                ADRVC   r1,remv
  108. i!                MOVVC   r2,#0
  109. j:                SWIVC   "XOS_Claim"       ; Claim RemV
  110. k!                MOVVC   r0,#6
  111. lQ                MOVVC   r3,#256           ; Claim 256 bytes for Wimp_Poll blk
  112. m(                SWIVC   "XOS_Module"
  113. n!                BVS     error
  114. o!                MOV     r5,#0
  115. pB                CMP     r4,#300           ; Check Wimp version
  116. q$                BLT     risc_os2
  117. r>                
  118. R     r5,r5,#1<<22      ; Check Poll word
  119. sF                
  120. R     r5,r5,#1          ; Don't return Null polls
  121. tD                ADR     r3,fEscPressed    ; Address of Poll word
  122. u$.risc_os2       STR     r2,[r12]
  123. v!.poll_lp        MOV     r0,r5
  124. w:                LDR     r1,[r12]          ; Poll block
  125. x(                SWI     "XWimp_Poll"
  126. y!                BVS     error
  127. z"                TEQ     r0,#17
  128. {"                TEQNE   r0,#18
  129.                 BEQ     msg
  130. }!                TEQ     r0,#0
  131. ~@                TEQNE   r0,#13            ; PollWord_NonZero
  132. #                BNE     poll_lp
  133. *                LDR     r0,fEscPressed
  134. !                TEQ     r0,#0
  135. #                BEQ     poll_lp
  136. F                MOV     r1,#0             ; Cancel drag by calling
  137. K                STR     r1,fEscPressed    ; Clear `Escape pressed' flag
  138. G                SWI     "XWimp_DragBox"   ; XWimp_DragBox with r1=0
  139. #                B       poll_lp
  140. '.msg            LDR     r0,[r1,#16]
  141. >                TEQ     r0,#0             ; Quit message ?
  142. #                BNE     poll_lp
  143. ).exit           BL      wimpclosedown
  144. %                SWI     "OS_Exit"
  145. B.error          MOV     r1,#%10           ; Cancel button only
  146. *                ADR     r2,description
  147. /                SWI     "XWimp_ReportError"
  148.                  B       exit
  149. @; Called by module initialisation entry and on Service_Reset
  150. &.init           STMFD   r13!,{r14}
  151. "                MOV     r14,#0
  152. M                STR     r14,th            ; Task not running, not claimed
  153. +                STR     r14,fEscPressed
  154. %                LDMFD   r13!,{PC}
  155. .finalise
  156. J; Calls Wimp_CloseDown if Wimp_Initialise has been successfully called
  157. @; (ie th > 0).  It sets th = 0 to indicate task not running.
  158. 1; Also, the workspace and vector are released
  159. ; /X r0-r6
  160. ".wimpclosedown  MOV     r6,r14
  161. ;                LDR     r0,th             ; Is th > 0 ?
  162. !                MOVS    r0,r0
  163. <                MOVPL   r0,#RemV          ; Release RemV
  164. #                ADRPL   r1,remv
  165. !                MOVPL   r2,#0
  166. )                SWIPL   "XOS_Release"
  167. !                LDRPL   r0,th
  168. #                LDRPL   r1,TASK
  169. -                SWIPL   "XWimp_CloseDown"
  170. $                LDR     r2,[r12]
  171. !                TEQ     r2,#0
  172. !                MOVNE   r0,#7
  173. H                SWINE   "XOS_Module"      ; Release block if claimed
  174. !                MOV     r0,#0
  175. $                STRNE   r0,[r12]
  176. A                STR     r0,th             ; Clear task handle
  177. !                MOV     PC,r6
  178. "; Buffer remove vector routine
  179. Q.remv           TEQ     r1,#0             ; Exit if it's not the keybd buffer
  180. N                STMEQFD r13!,{PC}         ; PC gives PC 3 words in advance
  181. "                MOV     PC,r14
  182.                 ;
  183. I.TASK           EQUS    "TASK"            ; Neatly fills one word gap
  184.                 ;
  185. E                LDMCSFD r13!,{PC}         ; Exit if remove failed
  186. '                TEQ     r2,#
  187. (esc$)
  188. O                LDMNEFD r13!,{PC}         ; Coded for speed in general case
  189. H                STR     r2,fEscPressed    ; Ignore if not in desktop
  190. %                LDMFD   r13!,{PC}
  191. "Size = ";P%" bytes"
  192.  "OS_File",&0A,fnm$,&FFA,,org,O%
  193.  "OS_Module",11,org,P%
  194. align
  195.  next line allows shuffling of strings to reduce wastage
  196. 2)=0 
  197. 3" byte(s) wasted by FNalign"
  198. 3:[OPTA%:EQUB0:]:
  199.